% Function : Principal Component Analysis
% Parameter:
%   A: each row is one sample(record) and each column is one feature(matrix)
% Return:
%   V: eigenvectors of A's covariance matrix(matrix)
%   D: eigenvalues of A's covariance matrix(diagonal matrix)
function [V, D] = PCA(A)
    % number of rows
    m = size(A, 1);

    % Step 1: normalization
    A = A - mean(A);
    % A = A ./ std(A);

    % Step 2: covariance matrix
    C = A' * A / m;

    % Step 3: eigenvectors and eigenvalues
    [V, D] = eig(C);
end
